<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            width: 200px;
            height: 200px;
            background-color: red;
        }

        .box2 {
            width: 100px;
            height: 100px;
            background-color: blue;
        }

        .box3 {
            width: 50px;
            height: 50px;
            background-color: green;
        }
    </style>


</head>

<body>
    <div class="box1">
        <div class="box2">
            <div class="box3"></div>
        </div>
    </div>
    <script>
        let box1 = document.querySelector('.box1')
        let box2 = document.querySelector('.box2')
        let box3 = document.querySelector('.box3')
        box1.addEventListener('click', function () {
            console.log('box1')
        }, false)//第三个参数表示是否在捕获阶段执行，默认是false，在冒泡阶段执行
        box2.addEventListener('click', function () {
            console.log('box2')
        }, false)
        box3.addEventListener('click', function () {
            console.log('box3')
        }, false)
    </script>


</body>

</html>